<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>入取分数线预测</title>
    <link href="frozen/css/frozen.css" rel="stylesheet">
    <style type="text/css">
        .demo-desc{
            padding: 10px;
        }
        .ui-form-item label:not(.ui-switch):not(.ui-checkbox):not(.ui-radio){
            width: 150px;
        }
        .ui-form-item input, .ui-form-item textarea{
            padding-left: 160px;
        }
    </style>
</head>
<body>
    <header class="ui-header ui-header-positive ui-border-b">
        <h1>入取分数线预测（安徽,一本）</h1>
    </header>
    <div id="input-panel" class="demo-item" style="margin-top:60px;">
        <p class="demo-desc">输入过去三年入取分数</p>
        <div class="demo-block">
            <div class="ui-form ui-border-t">
                <form action="#" >
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2013年入取平均分数</label>
                        <input type="text" value="" name="score2013" placeholder="请输入，没有可不填">
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2014年入取平均分数</label>
                        <input type="text" value="" name="score2014" placeholder="请输入，没有可不填">
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2015年入取平均分数</label>
                        <input type="text" value="" name="score2015" placeholder="请输入，没有可不填">
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2016年入取平均分数</label>
                        <input type="text" value="" name="score2016" placeholder="请输入，没有可不填">
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div id="result-panel" class="demo-item">
        <p class="demo-desc">结果</p>
        <div class="demo-block">
            <div class="ui-form ui-border-t">
                <form action="#" >
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2013年高于一本线</label>
                        <input type="text" value="" name="dscore2013" readonly>
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2014年高于一本线</label>
                        <input type="text" value="" name="dscore2014" readonly>
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2015年高于一本线</label>
                        <input type="text" value="" name="dscore2015" readonly>
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">2016年高于一本线</label>
                        <input type="text" value="" name="dscore2016" readonly>
                    </div>
                    <div class="ui-form-item ui-form-item-show ui-border-b">
                        <label for="#">平均高于一本线</label>
                        <input type="text" value="" name="dscoreavg" readonly>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="demo-item">
        <div class="demo-block"> 
            <div class="ui-btn-wrap">
                <button class="ui-btn-lg ui-btn-primary" id="start-btn">
                    开始计算
                </button>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="frozen/js/lib/zeptojs/zepto.min.js"></script>
    <script type="text/javascript" src="frozen/js/frozen.js"></script>
    <script type="text/javascript" src="/web-lib/js/h5x.js",></script>
    <script type="text/javascript" src="/web-lib/js/plugs/h5x-dai.js"></script>

    <script type="text/javascript">
        $(function(){
            $("#start-btn").click(function(){
                var score2013 = $("input[name='score2013']").val();
                var score2014 = $("input[name='score2014']").val();
                var score2015 = $("input[name='score2015']").val();
                var score2016 = $("input[name='score2016']").val();
                var dscore2013 = score2013 ? parseInt(score2013) - 490 : false;
                var dscore2014 = score2014 ? parseInt(score2014) - 489 : false;
                var dscore2015 = score2015 ? parseInt(score2015) - 555 : false;
                var dscore2016 = score2016 ? parseInt(score2016) - 518 : false;

                //console.log([dscore2013,dscore2014,dscore2015,dscore2016]);

                var scores = [dscore2013,dscore2014,dscore2015,dscore2016],total=0,c=0;
                scores.forEach(function(s){
                    if(s){
                        total+=s;
                        c++
                    }
                });

                var dscoreavg =  parseInt(total/c);

                //var dscoreavg =  parseInt((dscore2013+dscore2014+dscore2015+dscore2016)/4);
                $("input[name='dscore2013']").val(dscore2013||"");
                $("input[name='dscore2014']").val(dscore2014||"");
                $("input[name='dscore2015']").val(dscore2015||"");
                $("input[name='dscore2016']").val(dscore2016||"");
                $("input[name='dscoreavg']").val(dscoreavg);
                
            });
        });

        var apply_module = {};
        H5x.use(apply_module,"dai",{
            app_name:"home"
        });

        var applydai = apply_module.dai.create("apply");
        /*
        applydai.add({
            name:"123",
            telphone:"999",
            time:new Date()
        });

        
        */

        /*
        applydai.remove({id:"2i4nzqr0c"},function(rs){
            console.log(rs);
        });
        */

        
        /*/
        applydai.update({id:"32jp2gzcu"},{telphone:"8888"},function(rs){
            console.log(rs);
            applydai.query({},function(rs){
                console.log(rs);
            });
        });
        */

        applydai.get("32jp2gzcu",function(rs){
            console.log(rs);
            
        });


        applydai.query({_page:1,_size:5},function(rs){
            console.log(rs);
        });

    </script>
</body>
</html>